/*
** ressource.c for ressource in /home/mondes_l/Documents/SDL/mario
** 
** Made by louis mondesir
** Login   <mondes_l@louis-notebook>
** 
** Started on  Mon Apr 15 13:10:47 2013 louis mondesir
** Last update Mon Apr 15 19:14:16 2013 romain gjura
*/

#include <SDL/SDL.h>
#include "./includes/draw.h"

void	init_ressource(t_ressource *ressource)
{
  int	i = 0;

  ressource->r_tab[0] = SDL_LoadBMP("./ressources/background/sky.bmp");
  ressource->r_tab[1] = SDL_LoadBMP("./ressources/background/big_border_grass.bmp");
  ressource->r_tab[2] = SDL_LoadBMP("./ressources/background/gold_pipe.bmp");
  ressource->r_tab[3] = SDL_LoadBMP("./ressources/background/big_champi_left.bmp");
  SDL_SetColorKey(ressource->r_tab[3], SDL_SRCCOLORKEY,
		  SDL_MapRGB(ressource->r_tab[3]->format, 0, 0, 0));
  ressource->r_tab[4] = SDL_LoadBMP("./ressources/background/big_champi_middle.bmp");
  ressource->r_tab[5] = SDL_LoadBMP("./ressources/background/big_champi_right.bmp");
  SDL_SetColorKey(ressource->r_tab[5], SDL_SRCCOLORKEY,
		  SDL_MapRGB(ressource->r_tab[5]->format, 0, 0, 0));
  ressource->r_tab[6] = SDL_LoadBMP("./ressources/background/block_surprise.bmp");
  ressource->r_tab[7] = SDL_LoadBMP("./ressources/background/grass.bmp");
  ressource->r_tab[8] = SDL_LoadBMP("./ressources/background/lava.bmp");
  ressource->r_tab[9] = SDL_LoadBMP("./ressources/background/silver_pipe.bmp");
  ressource->r_tab[10] = SDL_LoadBMP("./ressources/background/stone_right_corne.bmp");
  ressource->r_tab[11] = SDL_LoadBMP("./ressources/background/stone_middle.bmp");

  ressource->pos.x = 0;
  ressource->pos.y = HEIGTH;

  while (i < 11)
    {
      if (ressource->r_tab[i] == NULL)
	{
	  printf("Error: SDL Failed: %s\n", SDL_GetError());
	  exit(EXIT_FAILURE);
	}      
      i++;
    }
}
